package com.yuanfeng.order.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanfeng.commoms.vo.fx.ShareGoodsVO;
import com.yuanfeng.commoms.vo.fx.VkApplyOrderVO;
import com.yuanfeng.commoms.vo.order.OrderCommissionVO;
import com.yuanfeng.order.dto.*;
import com.yuanfeng.order.entity.OrderCommissionEntity;
import com.yuanfeng.order.vo.TgUserInfoVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @ClassName OrderCommissionMapper
 * @Description 佣金订单
 * @Author cyp
 * @Date 2023-06-01 11:38:05
 * @Version 1.0
 **/
@Mapper
public interface OrderCommissionMapper extends BaseMapper<OrderCommissionEntity> {

    /**
     * 插入分佣订单
      * @param orderCommissionList
     */
    void insertBatch(@Param("record")List<OrderCommissionVO> orderCommissionList);

    /**
     * 修改分销订单状态
     * @param orderIdList
     * @return
     */
    int updateOrderStatusBatch(@Param("orderStatus") Integer orderStatus, @Param("orderIdList") List<String> orderIdList);

    /**
     * 查询 分销订单信息
     * @param orderIdList
     * @return
     */
    List<ShareGoodsVO> queryUserShareFirst(@Param("orderIdList") List<String> orderIdList);

    /**
     * 查询分销订单
     * @param orderId
     * @return
     */
    OrderCommissionVO selectByPrimaryKey(String orderId);

    /**
     * 查询订单信息
     * @param orderIdList
     * @return
     */
    List<VkApplyOrderVO> queryVkApplyOrder(List<String> orderIdList);


    /**
     * 查询用户微客信息
     * @param shopVKUser
     * @return
     */
    List<VKUserDTO> queryShopVkUser(VKUserDTO shopVKUser);


    /**
     * 查询用户佣金总额
     * @param userId
     * @return
     */
    Map<String,Object> queryShopVkUser1(String userId);

    /**
     * 佣金列表查询
     * @param param
     * @return
     */
    IPage<FxGoodsInfoDTO> queryFxGoodsList(IPage<FxGoodsInfoDTO> page , @Param("param") FxGoodsInfoDTO param);
    /**
     * 微客列表查询
     * @param param
     * @return
     */
    IPage<VKUserDTO> queryVkUserList(IPage<VKUserDTO> page , @Param("param") VKUserDTO param);

    /**
     * 更新佣金订单
     * @param record
     * @return
     */
    int updateByPrimaryKeySelective(@Param("param") OrderCommissionVO record);
    /**
     * 微客分佣订单
     * @param mallOrderQuery
     * @return
     */
    IPage<OrderCommissionVO> queryShopUserCommissionList(Page<OrderCommissionVO> page,@Param("param") MallOrderDTO mallOrderQuery);

    /**
     * 今日预计收益
     * @param settleList
     * @return
     */
    IPage<OrderCommissionVO> querySettleList(Page<OrderCommissionVO> page,@Param("param") FxOrderListDTO settleList);

    /**
     * 统计 购买人和分享人 是绑定关系的 订单
     * @param settleList
     * @return
     */
    BigDecimal queryTotalSettleAmount(@Param("param") FxOrderListDTO settleList);

    /**
     * 统计 购买人和分享人 不是绑定关系的 订单
     * @param settleList
     * @return
     */
    BigDecimal queryTotalNotBindSettleAmount(FxOrderListDTO settleList);
    /**
     * 推广用户列表
     * @param tgUser
     * @return
     */

    IPage<TgUserInfoVO> queryTodayTgUser(Page<TgUserInfoVO> page,@Param("param") TgUserDTO tgUser);

    /**
     * 查询用户支付 售后单详情
     * @param tgUser
     * @return
     */
    IPage<OrderCommissionVO> queryTgUserDetail(Page<OrderCommissionVO> page,@Param("param") TgUserDTO tgUser);


    /**
     * 佣金统计
     *
     * @param settleList
     * @return
     */
    Map<String, Object> queryTotalSettleAmountByUserCommission(@Param("param")FxOrderListDTO settleList);

    /**
     * 查询订单plus总折扣
     * @param orderId
     * @param goodsId
     * @return
     */
    Map selectplusdis(@Param("orderId") String orderId,@Param("list")List goodsId);
    /**
     * 查询佣金列表数据
     * @param param
     * @return
     */
    IPage<OrderCommissionVO> queryTgSettleList(IPage<OrderCommissionVO> page , @Param("param") FxOrderListDTO param);
}
